package com.itheima;

import com.itheima.pojo.Student;
import com.itheima.pojo.Teacher;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * Hello world!
 */
public class App {
    public static void main(String[] args) {

        //创建老师那个容器
        ClassPathXmlApplicationContext context1 = new ClassPathXmlApplicationContext("beans1.xml");

        Teacher teacher = context1.getBean(Teacher.class);

        System.out.println("获取容器1里面的老师:"+teacher);


        //创建学生容器
        ClassPathXmlApplicationContext context2 = new ClassPathXmlApplicationContext();

        //咋办呢?
        //创建容器的父子关系
        context2.setParent(context1);
        context2.setConfigLocation("beans2.xml");
        context2.refresh();

        Student student = context2.getBean(Student.class);

        System.out.println("获取容器2里面的学生:"+student);

    }
}
